package io.gitee.guoguoleo.utils;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class ListUtil {

    public static<T> List<List<T>> poList(Collection<T> list, long size){
        long limit = (list.size() + size - 1) / size;
        return Stream.iterate(0, n -> n + 1)
                .limit(limit)
                .map(a -> list.stream().skip(a * size).limit(size).collect(Collectors.toList()))
                .toList();
    }

}
